using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Web.SessionState;
using System.Data.Common;

namespace AJAXEnabledWebApplication1
{
    public partial class _Default : System.Web.UI.Page
    {
        static Database database;

        public void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack) {
                database = new Database();

            }            

            //}

        }

        protected void LoginButton_Click(object sender, EventArgs e)
        {
            string u_name = UserName.Text;
            string passw = Password.Text;
            int u_id = 0;

            u_id = database.isCorrectUser(u_name, passw);

            if (u_id > 0)
            {
                Session["id"] = u_id.ToString();
                Session["date"] = "";

                Response.Redirect("main.aspx");
            }
            else {
                Label1.Visible = true;
            }
        }

        protected void Calendar1_SelectionChanged(object sender, EventArgs e)
        {
            UserName.Text = Calendar1.SelectedDate.ToString();
        }

        
    }
}
